gnuplot memo

Links
Label example
    set xlabel 'M_{W}'
    set xlabel 'W{/Symbol \242}'  <--- W'  
    set xlabel '{/Symbol \243}'   <--- $\lesssim$
    set xlabel '{/Symbol \245}'   <--- $\infty$
    set xlabel '{/Symbol \256}'   <--- right arrow 
    set xlabel '{/Symbol \264}'   <--- $\times$
    set xlabel '{/Symbol W}'      <--- $\Omega$
    set xlabel '{/Symbol q}'      <--- $\theta$
    
    pdfcairo terminal test
Some commands
    set log y
    unset log y
    set logscale y
    unset logscale y
    
    set xrange [0:50]
    
    set title "{/Symbol W}_{DM} h^2"
    
    # 桁数だけ表示すればいいとき
    set format y "10^{%L}"
    
    # 指数で表示 (ただし、10ではなく e が使われる)
    set format y "%10.2e"
    
    # terminal のコマンドを打ちたければ ! で始めればよい。
    !less hoge.dat
    
    # pdf で出力(old)
    set term pdf
    set term pdf fsize 10  # フォントサイズを10 
    set term pdf fsize 10 size 5,5 # x幅を 5inch, y幅を 5inch に設定(デフォルトは 5,3)
    
    
    # pdf で出力(new: homebrew で入る gnuplot が何か新しくなったらしい)
    set term pdfcairo
    set term pdf cairo transparent enhanced fontscale 0.5 size 5.00in, 3.00in   (デフォルト)
    set term pdf cairo transparent enhanced font ",20" size 6, 6   (フォントサイズ20)
    
    
    
    
    # 1列目を小さい順に並べてからプロット
    # with line をやるとき便利な事がある。
    plot "< sort -g hoge.dat" w l
    
    # legends の位置の指定。
    set key right bottom
    
    # 破線
    - plot "hoge.dat" u 1:2 w l dt 2 lw 7
    - dt 1 が直線
    - dt 2 が破線
    - 数字を大きくすると点々が細かくなった。
    - dt (10,5) とすれば、破線の線の長さが 10, 隙間が 5 になる。単位は不明。
    
    
    # プロットの下側を軸までぬりつぶす
    - plot hoga.dat w filledcurves x1 lc 5
    - こうすると、軸が隠れてしまうので set tics front をどこかに書いておく。
    
    
    データをプロットして、データ点をドットで表示しつつ線で繋ぐ
    plot "hoge.dat" u 1:2 w linespoints
contours
    f(x,y) = 0.12029 となる contour を書きたいとき。
    データの中に 0.12029 が無くても適当に内挿してくれる。

    まず、データを用意する。形式は、

      x1 y1 f(x1,y1)
      x1 y2 f(x1,y2)
      x1 y3 f(x1,y3)
      
      x2 y1 f(x2,y1)
      x2 y2 f(x2,y2)
      x2 y3 f(x2,y3)
      
      x3 y1 f(x3,y1)
      x3 y2 f(x3,y2)
      x3 y3 f(x3,y3)
      
      ...
      
    途中でスペースを空けたのが重要。また、今の場合データが 3x3でひとつのブロックになっているが、すべてのブロックが同じ長方形になっていないといけない。

    データを用意した後のgnuplotのコマンドは

      set contour; unset surface; set view 0,0
      set log x; set log y; set log z
      unset ztics
      set cntrparam levels discrete 0.12029
      splot "../filename.dat" u 1:2:3 w l lw 7 notitle
      
    0.012, 0.12, 1.2 の3本を引きたい場合は、
      set cntrparam levels discrete 0.012, 0.12, 1.2
      

    描いた後に図のデータ点が欲しい場合がある。図はデータを補完して描いているので、下のデータに比べて、0.12029となる点が増えている。これを書き出すには、

      set table "hogehoge.tab"
      replot
      unset table
      
decimal point
    33/5=6
    33/5.=6.6
Tips
  • gnuplotをつかうときに"guplot &"と&をいれてはいけない。

  • 2つ目を 10^(36) 倍するとき。36. と点を付ける。 u 1:($2*10**(36.))